#include "thread_try.h"


static int num = 0;


void * add(){
    sleep(1);
    printf("add: %d\n", num);
    for(int i=0; i<10; i++){
        printf("add: %d\n", ++num);
        sleep(1);
    }
}

void * subs(){
    sleep(1);
    printf("subs: %d\n", num);
    for (int i=0; i<10; i++){
        printf("subs: %d\n", --num);
        sleep(1);
    }
}


int main(void){ 

    pid_t t_id1, t_id2;

    printf("main: %d\n", num);

    int a = 0;

    pthread_create(&t_id1, NULL, subs, (void *) &a);
    pthread_create(&t_id2, NULL, add, (void *) &a);

    sleep(10);
    // void * ans1, *ans2;
    // pthread_join(t_id1, &ans1);
    // pthread_join(t_id2, &ans2);
    printf("main: %d\n", num);
    return 0;
}